package com.zzb.framework.modules.param.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zzb.framework.modules.param.dao.mapper.SysParamMapper;
import com.zzb.framework.modules.param.entity.SysParam;
import com.zzb.framework.common.BaseDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * 系统配置表 DAO接口
 */
@Repository
public class SysParamDAO extends BaseDAO<SysParam> {

    @Autowired
    private SysParamMapper sysParamMapper;

    @Override
    public SysParamMapper getMapper() { return sysParamMapper; }

    public SysParam findTopByParamKey(String paramKey) {
        return getMapper().selectList(new QueryWrapper<SysParam>()
                .eq("param_key", paramKey)
                .orderBy(true, false, "create_time")
                .last("limit 1")).stream().findFirst().orElse(null);
    }
}
